		var retentDayArray=[];
          var editIndex = undefined;
          $('#tt').edatagrid({
           	url:"/retentlog/configList?mark="+$('#mark').val(),
            onClickRow: function(index){
            	 if($('#mark').val()==''){return};
                 if(index!=editIndex){
                     editIndex = index;
                  }
             },
             onLoadSuccess:function(data){
             	$(this).datagrid('enableDnd');
             	retentDayArray=[];

             	if(data.rows.length==0){
             		if($('#mark').val()==''){
             			 $('#tt').datagrid({
 	                        url:'',
 	                        data:''
             			 }); 
             		}
            	}else{
                  	$.each(data.rows,function(index,mod){
                		retentDayArray.push(mod.retentDay)
                	})
            	}
             },
             onBeforeSave:function(index){
            	 var taskNum=$("td[field='taskNum'] input").val();
            	 if(taskNum==''){
            		 return false; 
            	 }
             }
          });
         //查询
         function doSearch(){
          	$('#tt').edatagrid({
          		url:"/retentlog/configList?mark="+$('#mark').val()});
          	var rows = $('#tt').edatagrid('clearSelections');
         }
         
         //删除
         function remove(){
             //if (editIndex == undefined){return}
             //var row = $('#tt').datagrid('getSelected');
             //var array={retentMonth:row.retentMonth,taskNum:row.taskNum,mark:row.mark,execTimes:row.execTimes}
        	 //$.ajax({
 		  		//url:'/retentlog/deleteRetent',
 		  		//type:'post',
 		  		//dataType:"json",
 		  		//data:JSON.stringify(array),
 		  		//contentType:'application/json',
 		  		//success:function(){
 		  			//jQuery.messager.alert('提示:','删除成功!'); 
 		  			//editIndex = undefined;
 		  			//doSearch();
 		  		//}
 		  	//})
 		  	
 		  	var rows = $('#tt').edatagrid('getSelections');
 		  	if (rows === undefined || rows.length == 0 ) {
 		  		jQuery.messager.alert('提示:','请选择要删除的记录!'); 
 		  		return false;
 		  	}
		  	var arr = [];
		  	for (var i=0;i<rows.length;i++) {
		  		var retentLogConfig = {};
		  		retentLogConfig['retentMonth'] = rows[i].retentMonth;
		  		retentLogConfig['taskNum'] = rows[i].taskNum;
		  		retentLogConfig['mark'] = rows[i].mark;
		  		retentLogConfig['execTimes'] = rows[i].execTimes;
		  		arr.push(retentLogConfig)
		  	}
		  	
		  	$.ajax({
		  		headers: {
	                'Accept': 'application/json',
	                'Content-Type': 'application/json'
	            },
		  		url:'/retentlog/batchDelete',
		  		type:'POST',
		  		data: JSON.stringify(arr),
		  		async: true,
	            dataType: "json",
		  		success:function(){
	  				jQuery.messager.alert('提示:','删除成功!'); 
		  			doSearch();
		  		}
		  	})
           
         }
         
         //添加
         function addRow(){
         	var markId=$('#mark').val();
         	if(markId==''){return}
         	var file='/resources/js/easyui/datagrid-dnd.js';
         	$('#tt').edatagrid('appendRow', {
         		mark:markId,    
         		retentMonth:'',
         		execTimes:'0',
                taskNum:'0'
            });
            $('#tt').datagrid('enableDnd');
         }

          //保存
		function saveRow(){
		    var markId=$('#mark').val();
         	if(markId==''){return}
            var newRow=[];
            var arrayLen=0;
            $('#tt').edatagrid('saveRow')
            var initRow=$("#tt").datagrid('getRows');
 		  	$.each(initRow,function(index,mod){
 		  		var	array={};
 		  		array={apkId:mod.apkId,retentMonth:mod.retentMonth,taskNum:mod.taskNum,mark:markId,execTimes:mod.execTimes};
 		  		newRow.push(array);
 		  		arrayLen=newRow.length;
		  	})
		  
		  	$.ajax({
		  		url:'/retentlog/saveConfig',
		  		type:'post',
		  		dataType:"json",
		  		data:JSON.stringify(newRow),
		  		contentType:'application/json',
		  		success:function(){
		  			jQuery.messager.alert('提示:','成功保存'+arrayLen+'条数据!'); 
		  			doSearch();
		  		}
		  	})
            
        }
        //输入框限制为数字
		$(document).on("keyup afterpaste","td[field='taskNum'] input",function(){
			this.value=this.value.replace(/\D/g,'');
		})
		
		//全选
        function selectAll(){
        	 $('#tt').datagrid('selectAll');
        }
  
	  
		